package org.opens.controller;

import org.opens.entity.MyBatisPerson;
import org.opens.service.MyBatisPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/api/mybatis/person")
public class MyBatisPersonController {

    @Autowired
    private MyBatisPersonService myBatisPersonService;

    @RequestMapping(value = "/{id}")
    public MyBatisPerson queryById(
            @PathVariable(value = "id") Integer id
    ) {
        try {
            MyBatisPerson myBatisPerson = myBatisPersonService.queryOneByPK(id);
            return myBatisPerson;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

}
